package com.zte.user.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zte.user.dao.IUserDao;
import com.zte.user.model.Student;
import com.zte.user.model.Teacher;
import com.zte.user.model.Users;
import com.zte.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class IUsreServiceImpl implements IUserService {
    @Autowired
    private IUserDao userDao;

    @Override
    public List<Users> login(Users users) {
        return userDao.login(users);
    }

    @Override
    public List<Users> findAll(Users users) {
        return userDao.findAll(users);
    }

    @Override
    public PageInfo<Users> findPagebyAll(PageInfo<Users> info, Users users) {
        PageHelper.startPage(info.getPageNum(),info.getPageSize());
        List<Users> users1 = userDao.findAll(users);
        PageInfo<Users> pageInfo = new PageInfo<>(users1);
        return pageInfo;
    }

    @Override
    public boolean addStu(Student student) {
        return userDao.addStu(student);
    }

    @Override
    public boolean addUser(Users users) {
        return userDao.addUser(users);
    }

    @Override
    public boolean addTeacher(Teacher teacher) {
        return userDao.addTeacher(teacher);
    }
}
